package com.xmb.common.service.impl;

import com.xmb.common.dao.XmbSpreadRewardRecordMapper;
import com.xmb.common.entity.XmbSpreadRewardRecord;
import com.xmb.common.service.SprendRewardRecordService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * Created by lyndon on 2019/4/10.
 */
@Service
public class SprendRewardRecordServiceImpl implements SprendRewardRecordService{

    @Resource
    private XmbSpreadRewardRecordMapper spreadRewardRecordMapper;

    @Override
    public Long saveSprendRewardRecord(XmbSpreadRewardRecord rewardRecord) {
        spreadRewardRecordMapper.insertSelective(rewardRecord);
        return rewardRecord.getId();
    }

    @Override
    public boolean checkIsNeedGiftReward(Long uid, Long activityId, String path) {
        XmbSpreadRewardRecord rewardRecord = new XmbSpreadRewardRecord();
        rewardRecord.setPath(path);
        rewardRecord.setActivityId(activityId);
        rewardRecord.setIsVaild(Boolean.TRUE);
        rewardRecord.setUserId(uid);
        return spreadRewardRecordMapper.findRewardRecord(rewardRecord) == null;
    }
}
